in ⁄ not in
if <object> in <sequence>:
<if body>
if <object> not in <sequence>:
<if body>
Checks for membership of object within a sequence.
- Operators:
- in :
- Checks if object is a member of a sequence
- not in :
- Checks if object is not a member of a sequence
- Returns:
- True or False.
- Return Type:
- Boolean
id_ser = pets.get('ID')
id_ser
- 0"dog_001"
- 1"cat_001"
- 2"cat_002"
- 3"dog_002"
- 4"dog_003"
- 5"ham_001"
- 6"ham_002"
- 7"cat_003"
def cat_and_dog_info(pet_id):
id_arr = np.array(pets.get('ID'))
if pet_id not in id_arr:
return 'This pet is not in our record'
cat_and_dog_info('cat_009')
'This pet is not in our record'